import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;


public class UpdateFileManager implements Runnable{

	PrintWriter printWriter;
	ArrayList<Student> students = new ArrayList<Student>();

	public ArrayList<Student> getStudents() {
		return students;
	}

	public void setStudents(ArrayList<Student> students) {
		this.students = students;
	}

	@Override
	public void run() {


		try {

			printWriter = new PrintWriter(new BufferedWriter(new FileWriter(
					"student.txt", false)));

			for (Student student : students)
			{
				printWriter.write(student.getName());
				printWriter.write("#");
				printWriter.write(student.getSurname());
				printWriter.write("#");
				printWriter.write(student.getStudNumber());
				printWriter.write("#");
				printWriter.write(student.getCourse());
				printWriter.write("#");
				printWriter.write(student.getDepartment());
				printWriter.write("#");
				printWriter.write(student.getAddress());
				printWriter.write("\n");
			}


		} catch (IOException e) {
			e.printStackTrace();
		}
		finally
		{
			printWriter.flush();
			printWriter.close();
		}

	}

}
